import Vue from 'vue'
import LookImgCompontent from './index.vue'

let instance

const LookImgConstructor = Vue.extend(LookImgCompontent)

instance = new LookImgConstructor({
  el: document.createElement('div')
})

instance.show = false
const lookImg = {
  show (url) {
    if (url) {
      instance.url = url
      instance.show = true
      instance.isSmall = false
      document.body.appendChild(instance.$el)
    }
  },
  showSmall (url) {
    if (url) {
      instance.url = url
      instance.show = true
      instance.isSmall = true
      document.body.appendChild(instance.$el)
    }
  }
}

export default {
  install (Vue, options) {
    if (!Vue.$lookImg) {
      Vue.$lookImg = lookImg
    }
    Vue.mixin({
      created () {
        this.$lookImg = Vue.$lookImg
      }
    })
  }
}
